package com.akkainaction.tool.io.streams.source;

import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.stream.ActorMaterializer;
import akka.stream.Materializer;
import akka.stream.javadsl.Source;

import java.util.ArrayList;
import java.util.List;

public class TestSource {

    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("sys");
        //materializer主要用来给流分配Actor并驱动其执行
        Materializer materializer = ActorMaterializer.create(system);
        List<String> list = new ArrayList<>();
        list.add("sh");
        list.add("bj");
        list.add("nj");
        Source<String, NotUsed> s1= Source.from(list);
        s1.runForeach(System.out::println, materializer);
    }
}
